//
//  VRProtocol.h
//  Pods
//
//  Created by 陈长青 on 2017/3/25.
//
//

#ifndef VRProtocol_h
#define VRProtocol_h

/// MARK: - 从后台或别的场景切换回来恢复之前播放状态

typedef NS_ENUM(NSInteger, CQVPWillChangeStatus) {
    CQVPWillChangeStatusPlaying,// 正在播放
    CQVPWillChangeStatusPause   // 暂停
};

/// MARK: - 播放器协议

@protocol CQVRRenderViewProtocol;
@class AVPlayer;
@protocol CQVideoPlayerProtocol <NSObject>

@required

// 构造方法

- (id)initWithURL:(NSURL *)assetURL;

// 释放

- (void)free;

//视频标题

@property (strong, nonatomic) NSString *videoTitle;

//VR渲染视图

@property (nonatomic, weak) id<CQVRRenderViewProtocol> vrRenderView;

//系统播放器对象

@property (strong, nonatomic, readonly) AVPlayer *player;

//从后台或别的场景切换回来恢复之前播放状态

@property (assign, nonatomic) CQVPWillChangeStatus willChangeStatus;

// 当前播放时间

@property (assign, nonatomic) NSTimeInterval currentTime;

// 视频总时间

@property (assign, nonatomic) NSTimeInterval totalDuration;

//是否正在播放

-(BOOL)isPlaying;

//播放

-(void)play;


//暂停

-(void)pause;

//停止

-(void)stop;

//开始滑动进度条

-(void)scrubbingDidStart;

//正在滑动进度条

-(void)scrubbedToTime:(NSTimeInterval)time;

//结束滑动进度条

-(void)scrubbingDidEnd;

//调整播放时间

-(void)jumpedToTime:(NSTimeInterval)time;

//获取视频数据

-(CVPixelBufferRef)getPixelBuffer;

@end

/// MARK: - 播放器控制界面回调
@protocol CQVideoControlViewProtocol;
@protocol CQVideoControlViewDelegate <NSObject>

//点击返回

- (void)clickedBack:(id<CQVideoControlViewProtocol>)videoControlView;

//点击全屏

- (void)clickedFullScreen:(id<CQVideoControlViewProtocol>)videoControlView;

@end

/// MARK: - 播放器控制界面协议

@protocol CQVRRenderViewProtocol;
@protocol CQVideoControlViewProtocol <NSObject>

@required

//VR渲染视图

@property (nonatomic, weak) id<CQVRRenderViewProtocol> vrRenderView;

//播放器控制界面回调

@property (nonatomic, weak) id<CQVideoControlViewDelegate> delegate;

// 隐藏返回按钮

- (void)hideBack:(BOOL)hide;

// 隐藏上一个场景按钮

- (void)hidePre:(BOOL)hide;

// 隐藏下一个场景按钮

- (void)hideNext:(BOOL)hide;

//设置视频标题

-(void)setTitle:(NSString *)title;

//更新播放进度

-(void)setCurrentTime:(NSTimeInterval)time duration:(NSTimeInterval)duration;

//处理播放完成

-(void)playbackComplete;

//处理播放暂停

-(void)setToPlaying:(BOOL) isPlaying;

// 适配方向

-(void)fitScreenDirection:(BOOL)isHorizontalScreenDirection;

@end

/// MARK: - VR渲染视图数据源协议

@class CQScene;
@class CQModel;
@protocol CQVRRenderViewDataSource <NSObject>

@required

//场景个数

-(NSInteger)numberOfScenesInVRPlayer:(id<CQVRRenderViewProtocol>)vrRenderView;

//指定场景有多少物体

-(NSInteger)vrRenderView:(id<CQVRRenderViewProtocol>)vrRenderView numberOfModelsInScene:(NSInteger)sceneIndex;

//返回场景

-(CQScene *)vrRenderView:(id<CQVRRenderViewProtocol>)vrRenderView sceneAtIndex:(NSInteger)sceneIndex;

//放回物体

-(CQModel *)vrRenderView:(id<CQVRRenderViewProtocol>)vrRenderView modelForSceneAtIndex:(NSIndexPath *)indexPath;

@end

/// MARK: - VR渲染视图协议

@protocol CQVRRenderViewProtocol <NSObject>

@required

//是否横屏

@property (assign, nonatomic) BOOL isHorizontalScreenDirection;

//播放器控制界面（播放器控制界面随播放器状态改变）

@property (weak, nonatomic) id<CQVideoControlViewProtocol> videoControlView;

//VR渲染视图数据源协议

@property (nonatomic, weak) id<CQVRRenderViewDataSource> dataSource;

//上一个场景

@property (weak, nonatomic, readonly) CQScene *preScene;

//当前场景

@property (weak, nonatomic, readonly) CQScene *currentScene;

//是否分屏

@property (nonatomic, assign) BOOL duralScreenEnabled;

//重力感应

@property (nonatomic, assign) BOOL gyroscopeEnabled;

//刷新

-(void)reloadData;

//切下一个场景

-(void)switchNextScene;

//切上一个场景

-(void)switchPreviousScene;

//切指定场景

-(void)switchSceneByIndex:(int)index;

@end

#endif /* VRProtocol_h */
